package com.hualan.sfzyproject.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzyproject.domain.CourseReviews;
import com.hualan.sfzyproject.domain.CourseTypes;
import com.hualan.sfzyproject.domain.Courses;
import com.hualan.sfzyproject.mapper.CourseReviewsMapper;
import com.hualan.sfzyproject.mapper.CourseTypesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CourseReviewsService
 * @Description TODO
 * @Author libowen
 * @Date 2025年01月09日 8:50
 * @Version 1.0
 */
@Service
public class CourseReviewsService {
    @Autowired
    private CourseReviewsMapper courseReviewsMapper;
    public int insert(CourseReviews courseReviews) {
        return courseReviewsMapper.insert(courseReviews);
    }
    public int update(CourseReviews courseReviews) {
        return courseReviewsMapper.updateByPrimaryKeySelective(courseReviews);
    }
    public int delete(Long courseReviewsId) {
        return courseReviewsMapper.deleteByPrimaryKey(courseReviewsId);
    }
    //批量删除
    public boolean batchDelete(List<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            return false;
        }
        return courseReviewsMapper.batchDelete(ids) > 0;
    }
    //模糊查询
    public PageInfo<CourseReviews> search(String keyword, Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<CourseReviews> list = courseReviewsMapper.searchCourseReviews(keyword);
        return new PageInfo<>(list);
    }
    public PageInfo<CourseReviews> selectAll(Integer page,Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<CourseReviews> list = courseReviewsMapper.findReviews();
        return new PageInfo<>(list);
    }



}
